

import { registerClass } from "../../../cfw/tools/class_decorator";
import BaseAd from "../../core/base/BaseAd";
import { ResultState } from "../../SDKDefine";

@registerClass('QQRewardAd')
export default class QQRewardAd extends BaseAd {
    hide(): void {

    }

    load(): void {
        if (this.ad) {
            this.ad.load();
        }
    }

    destroy(): void {

    }
    onClose(res: any) {
        console.log('NativeTest onClose ', res)
        if (res && res.isEnded || res === undefined) {
            this.callResultCallback(ResultState.YES)
        } else {
            this.callResultCallback(ResultState.NO)
        }
    }
    create(): void {
        console.log(' 不支持多例')
        if (!this.ad) {
            console.log(' create 111111')
            this.ad = this.sdk.createRewardedVideoAd({ adUnitId: this.adUnitID })
            this.ad.onLoad(this.getFunc(this.onLoad))
            this.ad.onError(this.getFunc(this.onError))
            this.ad.onClose(this.getFunc(this.onClose))
        } else {

        }
        console.log(' create 2222')
        this.load();

    }

    show() {
        if (this.ad) {
            console.log(' 展示激励视频 ')
            this.ad.show()
        }
    }


}
